package test.thread;

public class ProductStack {
	
	private String name;
	private String[] buffer = new String[200];
	private int point=-1;
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the buffer
	 */
	public String[] getBuffer() {
		return buffer;
	}

	/**
	 * @param buffer the buffer to set
	 */
	public void setBuffer(String[] buffer) {
		this.buffer = buffer;
	}

	/**
	 * @return the point
	 */
	public synchronized int getPoint() {
		return point;
	}

	/**
	 * @param point the point to set
	 */
	public void setPoint(int point) {
		this.point = point;
	}

	public synchronized String pop(){
		String goods = buffer[point];
		buffer[point] = null;
		Thread.yield();
		point--;
		return goods;
	}
	
	public synchronized void push(String goods){
		point++;
		Thread.yield();
		buffer[point] = goods;
	}
	 
}
